﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using AspNetCs.Model;
using AspNetCs.Common;

public partial class Admin_number : Admin_BasePage
{
    protected string WhereStr = "";
    protected SaleNumber Sale = new SaleNumber();
    private string Action = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        //TODO:2009年9月10号 正在做JS验证
        IsExit();
        RequestStr();

    }
    private void RequestStr()
    {
        if (!String.IsNullOrEmpty(Request["action"]))
        {
            Action = Request["action"].ToString();
        }
        switch (Action)
        {
            case "add":
                this.Pl_Add.Visible = true;
                this.Pl_Manager.Visible = false;
                if (!Page.IsPostBack)
                {
                    #region 绑定所属类型
                    this.ChannelType.DataSource = Channel.ChannelBind();
                    this.ChannelType.DataValueField = "key";
                    this.ChannelType.DataTextField = "value";
                    this.ChannelType.DataBind();
                    #endregion
                }
                break;
            default:
                this.Pl_Add.Visible = false;
                this.Pl_Manager.Visible = true;
                if (!Page.IsPostBack)
                {
                    bind();
                }
                break;
        }
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bind();
    }
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {

    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        SaleNumber_Model model = new SaleNumber_Model();
        model.Number = Txt_Num.Text.ToString();
        model.SaleType = StringHelper.isNumber_int(ChannelType.SelectedValue);
        model.MemberPrice = StringHelper.isNumber_decimal(Txt_MemberPrice.Text);
        model.AgentPrice = StringHelper.isNumber_decimal(Txt_AgentPrice.Text);
        model.ReCommend = StringHelper.isNumber_int(IsCommend.SelectedValue);
        if (Sale.add(model) != -1)
        {
            ResultStr("Admin_number.Aspx", "添加成功！");
        }
        else
        {
            ShowMsgBack("添加失败！");
            Response.End();
        }
    }
    protected void bind() {
        this.AspNetPager1.PageSize = 25;
        Pager p = new Pager();
        p.Ident = "id";
        p.Obj = Repeater1;
        p.Orderfld = "Addtime";
        p.OrderType = "desc";
        p.PageIndex = this.AspNetPager1.CurrentPageIndex;
        p.PageSize = this.AspNetPager1.PageSize;
        p.TableName = "SaleNumber";
        p.WhereStr = WhereStr;
        p.ControlBind();
        this.AspNetPager1.RecordCount = p.recordcount();

    }


}
